package org.game;

import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.game.obj.LoginServerContext;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
@Slf4j
@Component
public class LoginServerManager {

    private Map<Integer, LoginServerContext> loginServerContextMap = new HashMap<>();


    public void registerLoginServer(int serverId, Channel channel) {
        if (loginServerContextMap.containsKey(serverId)) {
            log.error("游戏服节点已经注册 serverId = {}", serverId);
            return;
        }
        loginServerContextMap.put(serverId, new LoginServerContext(serverId, channel));
    }

    public LoginServerContext getLoginServerContext(int serverId) {
        return loginServerContextMap.get(serverId);
    }
}
